<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<%@ page contentType="text/html; charset=utf-8"%>
	<%@ include file="/commons/taglibs.jsp"%>

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
		<title>用户角色</title>

		<%@ include file="/commons/css_js_head.jsp"%>
		<script src="${ctx }/main/coommonjs/common.js" type="text/javascript"></script>


		<script type="text/javascript">
//复写Url
doListUrl = "${ctx }/permission/efUserRoleAction!doList.ts";
doSaveUrl = "${ctx }/permission/efUserRoleAction!doSave.ts";

function doSave(roleId) {
	var _form = document.forms[0];
	if (doSaveUrl == '') {
		alert('请设置正确的URL!');
		return false;
	}
	
	if(!onCheckSelectedOneCheckBox('chkId')){
		alert('请至少选择一个用户');
		return false;
	}
	
	var getValue = onGetValueFromSelectedCheckBox("chkId");
	
	_form.action = doSaveUrl+"?userIds="+getValue+"&roleId="+roleId;
	_form.submit();
}

</script>


	</head>
	<body style="overflow-x: hidden">

		<!-- 标题 -->
		<div class="mTitle">
			<span class="hidsearch"><a href="javascript:void(0)"
				onClick="return chg('searchList');" id="ImgArrow"> <img
						src="${ctx}/images/icon_up.gif" id="imgButton" />
			</a> </span>
			<b class="bbig">用户列表</b>
		</div>

		<!--list -->
		<div class="searchBar" id="searchList" style="display: block;">
			<form action="/permission/efUserRoleAction!doList.ts" method="post">
				<table class="searchTable">
					<tr>
						<th>
							用户名称：
						</th>
						<td>
							<s:textfield name="userName" theme="simple"></s:textfield>
						</td>
						<th>
							用户账号：
						</th>
						<td>
							<s:textfield name="userAccount" theme="simple"></s:textfield>
						</td>
					</tr>
					<tr>
						<td colspan="4">
							<input name="btn_query" type="button" class="btn" value="查询"
								onclick="doQuery()" />
							<input name="btn_reset" type="button" class="btn" value="清空查询条件"
								onclick="doReset()" />
							<input name="btn_query" type="button" class="btn" value="确定"
								onclick="doSave('${requestScope.roleId}')" />
						</td>
					</tr>
				</table>
			</form>
		</div>
		<div class="mainList">

			<table class="listTable">
				<tr>
					<th width="20px"><input id="chkAll" type="checkbox" /></th>
					<th>
						用户名称
					</th>
					<th>
						用户账号
					</th>
					<th>
						所属机构
					</th>
					<th>
						用户状态
					</th>
				</tr>

				<c:forEach var="user" items="${voList}">
					<tr align=center>
						<td><input name="chkId" type="checkbox" value="${user.userId}" />
						</td>
						<td>
							${user.userName}
						</td>
						<td>
							${user.userAccount}
						</td>
						<td>
							${user.efOrg.orgName}
						</td>
						<td>
							<c:if test="${user.dicUserIsValid==1}">
								<span class="icon_yes">&nbsp;</span>
							</c:if>
							<c:if test="${user.dicUserIsValid==0}">
								<span class="icon_no">&nbsp;</span>
							</c:if>
							<ef:CodeToName groupname="DicUserIsValid"
								translateValue="${user.dicUserIsValid}"></ef:CodeToName>
						</td>
					</tr>
				</c:forEach>
			</table>
		</div>
		<!--end list -->

		<div class="Toolbar">
			
		</div>

<script>
//为全选框chkAll加上事件
initSelectAllCheckBox('chkAll','chkId');

//获取该角色已经关联的用户
var selectedUserRole = new Array();
<c:forEach var="userRole" items="${requestScope.efUserRoleList}" varStatus="status">
	selectedUserRole[<c:out value="${status.index}" />] = '<c:out value="${userRole.efUser.userId}" />';
</c:forEach>


var checkBoxs = document.getElementsByName("chkId");
for(var i=0;i<checkBoxs.length;i++)
{
	var c = checkBoxs[i];
	var cValue = c.value;
	for(var j=0;j<selectedUserRole.length;j++)
	{
		var userId = selectedUserRole[j]
		if(cValue == userId) c.checked = true;
	}
	
}

var pageMsg = '${requestScope.pageMsg}'
if(pageMsg != ""){
	alert(pageMsg);
}

</script>

	</body>
</html>
